package com.hldsmart.smartda.activity.home;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.hldsmart.smartda.R;
import com.hldsmart.smartda.base.BaseActivity;
import com.hldsmart.smartda.utils.getMacAddress;

import butterknife.Bind;
import butterknife.ButterKnife;


public class SecurityActivity extends BaseActivity implements View.OnClickListener {

    @Bind(R.id.iv_security_back)
    ImageView iv_security_back;
    @Bind(R.id.tv_macAddress)
    TextView tv_macAddress;
    @Bind(R.id.tv_Android_info)
    TextView tv_Android_info;


    public static void startSecurityActivity(Context context) {
        Intent intent = new Intent(context, SecurityActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_security);
        ButterKnife.bind(this);
        setListener();
        String mac=getMacAddress.getLocalMacAddressFromWifiInfo(getApplication());
        String macID = mac.replaceAll(":", "").trim().toUpperCase();

        tv_macAddress.setText("设备MAC地址: "+mac+"\n设备标识："+macID);

        getAndroidInfo(getApplication());
    }

    public void getAndroidInfo(Context context) {
        TelephonyManager mTm = (TelephonyManager)context.getSystemService(TELEPHONY_SERVICE);
        String imei = mTm.getDeviceId();
        String imsi = mTm.getSubscriberId();
        String mtype = android.os.Build.MODEL; // 手机型号
        String numer = mTm.getLine1Number(); // 手机号码，有的可得，有的不可得

        tv_Android_info.setText("手机型号："+mtype+"\n手机号："+numer+"\nIMEI信息："+imei+"\nIMSI描述："+imsi);




    }


    private void setListener() {
        iv_security_back.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_security_back:
                finish();
                break;
        }
    }
}